home *** CD-ROM | disk | FTP | other *** search
/ Aminet 51 / Aminet 51 (2002)(GTI - Schatztruhe)[!][Oct 2002].iso / Aminet / gfx / fract / FlashMandelWOS.lha / FlashMandel / ARexx / _create_fm-anim.rexx < prev    next >
Encoding:
OS/2 REXX Batch file  |  2002-04-24  |  17.3 KB  |  466 lines

  1. /* _create_fm-anim.rexx
  2.  
  3.    Create a FlashMandelWOS-iff-animation by GUI.
  4.  
  5.    © 2002 Edgar Schwan
  6.  
  7.    $VER: _create_fm-anim.rexx 1.0 (23.4.2002)
  8.  
  9.    Some parts are taken and modified from 'ArtConvert.rexx 1.6 (4.5.2000) (C)' by Martin Steigerwald.
  10. */
  11.  
  12. PARSE ARG app.portname ' ' .
  13. IF app.portname = "" THEN
  14.    app.portname = "FLASHMANDEL.1";
  15. ADDRESS VALUE app.portname;
  16.  
  17. OPTIONS RESULTS;
  18. OPTIONS FAILAT 21;
  19.  
  20. SIGNAL ON SYNTAX;
  21. SIGNAL ON HALT;
  22. SIGNAL ON BREAK_C;
  23.  
  24. IF ~SHOW('L','rexxsupport.library') THEN DO
  25.    IF ~ADDLIB('rexxsupport.library', 0, -30) THEN
  26.       SAY "Error: Could not open 'rexxsupport.library'";
  27.    END;
  28.  
  29. app.DEBUG = 0; app.TRACE_FLAG = 0; app.USE_PRESETS = 0;     /* internal script-settings */
  30. app.TEMP_DIR = "t:";
  31. app.TEMP_FILENAME = "pic";
  32. app.GFXCON_PATH = "FLASHMANDEL:arexx/c/GfxCon";
  33. app.BUILDANIM_PATH = "FLASHMANDEL:arexx/c/BuildAnim";
  34. app.SCALE_SCRIPT_PATH = app.TEMP_DIR || "scale.script";
  35. /*app.PUBSCREEN = "Workbench";*/
  36. app.PUBSCREEN = app.portname;
  37.  
  38. resolution.count = 8;
  39. resolution.0.width = 80; resolution.0.height = 60;
  40. resolution.1.width = 160; resolution.1.height = 120;
  41. resolution.2.width = 320; resolution.2.height = 240;
  42. resolution.3.width = 640; resolution.3.height = 480;
  43. resolution.4.width = 800; resolution.4.height = 600;
  44. resolution.5.width = 1024; resolution.5.height = 768;
  45. resolution.6.width = 1280; resolution.6.height = 1024;
  46. resolution.7.width = 1600; resolution.7.height = 1200;
  47. anim_fmt.0 = "ANIM5"; anim_fmt.1 = "ANIM7S"; anim_fmt.2 = "ANIM7L";
  48.  
  49. IF ~Init() THEN DO
  50.    Cleanup();
  51.    EXIT 10;
  52.    END;
  53.  
  54. CALL LoadConfig();
  55.  
  56. res = CreateFMAnim_Dialog();
  57. IF res = 1 THEN DO
  58.    CALL CreateAnimation();
  59.    END;
  60.  
  61. CALL Cleanup();
  62. EXIT 0;
  63.  
  64. BREAK_C:     /* Handle HALT- and BREAK_C-event */
  65. HALT:
  66.    Cleanup();
  67.    EXIT 5;
  68.  
  69. SYNTAX:      /* Handle error */
  70.    SAY 'Error:' RC',' ERRORTEXT(RC) 'in line' SIGL'.';
  71.    Cleanup();
  72.    EXIT 10;
  73.  
  74.                                             /*** Subroutines ***/
  75. /* CreateFMAnim_Dialog(): */
  76. CreateFMAnim_Dialog: PROCEDURE EXPOSE app. config. resolution.
  77.    res = 0;
  78.  
  79.    pipe = CreateFMAnim_OpenGUI();
  80.    IF pipe ~== "gui_err" THEN DO
  81.       ;
  82.       /*CALL DisplayRequest(app.name, "Trace-Stop", "OK", app.PUBSCREEN);*/
  83.  
  84.       DO WHILE ~EOF(pipe)
  85.          CALL topipe(pipe, "continue");
  86.          line = READLN(pipe);
  87.          PARSE VAR line arg1 arg2 arg3 arg4
  88.          SAY "message: arg1:" arg1 "arg2:" arg2 "arg3:" arg3 "arg4:" arg4;
  89.          IF arg1 == "gadget" THEN DO
  90.             IF arg2 = gads.path THEN config.PATH = STRIP(arg4);          /* path-gadget */
  91.             IF arg2 = gads.animformat THEN config.ANIM_FORMAT = arg3;    /* animformat-gadget */
  92.             IF arg2 = gads.numframes THEN config.NUM_FRAMES = arg3;      /* numframes-gadget */
  93.             IF arg2 = gads.direction THEN config.DIRECTION = arg3;       /* direction-gadget */
  94.             IF arg2 = gads.scale THEN DO                                 /* scale-gadget */
  95.                config.SCALE = arg3;
  96.                CALL topipe(pipe, 'id='gads.destwidth' disable='1-config.SCALE' refresh');
  97.                CALL topipe(pipe, 'id='gads.destheight' disable='1-config.SCALE' refresh');
  98.                CALL topipe(pipe, 'id='gads.resolution' disable='1-config.SCALE' refresh');
  99.                END;
  100.             IF arg2 = gads.destwidth THEN config.DEST_WIDTH = arg3;      /* destwidth-gadget */
  101.             IF arg2 = gads.destheight THEN config.DEST_HEIGHT = arg3;    /* destheight-gadget */
  102.             IF arg2 = gads.resolution THEN DO                            /* resolution-gadget */
  103.                IF arg3 ~= 0 THEN DO
  104.                   arg3 = arg3 - 1;
  105.                   config.DEST_WIDTH = resolution.arg3.width;
  106.                   config.DEST_HEIGHT = resolution.arg3.height;
  107.                   END;
  108.                ELSE DO
  109.                   res = checkresolution(config.DEST_WIDTH, config.DEST_HEIGHT);
  110.                   IF res ~= 0 THEN CALL topipe(pipe, 'id='gads.resolution' selected='res' refresh');
  111.                   END;
  112.                CALL topipe(pipe, 'id='gads.destwidth' defnumber 'config.DEST_WIDTH' refresh');
  113.                CALL topipe(pipe, 'id='gads.destheight' defnumber 'config.DEST_HEIGHT' refresh');
  114.                END;
  115.             IF arg2 = gads.create THEN DO        /* create-gadget */
  116.                res = 1; CALL SaveConfig(); LEAVE;
  117.                END;
  118.             IF arg2 = gads.cancel THEN LEAVE;    /* cancel-gadget */
  119.             END;
  120.          IF arg1 == "close" THEN LEAVE;
  121.          END;
  122.  
  123.       CALL CLOSE(pipe);
  124.       END;
  125.  
  126.    ELSE DO
  127.       CALL DisplayRequest(app.name, getstr(300, "Error: Could not open user interface!"), getstr(100, "OK"), app.PUBSCREEN);
  128.       END;
  129.  
  130.    RETURN res;
  131.  
  132. /* CreateFMAnim_OpenGUI(): Open window for user-definitions. */
  133. CreateFMAnim_OpenGUI: PROCEDURE EXPOSE app. config. gads. resolution.
  134.    IF OPEN(pipe, "AWNPIPE:CreateFMAnimGUI/xc") THEN DO
  135.       CALL topipe(pipe, 'title="'app.name'" centerscreen vertical closegadget sizegadget depthgadget dragbar spaceinner activate modify pubscreen='app.PUBSCREEN);
  136.  
  137.       CALL topipe(pipe, "layout bevel=0 vertical spaceinner spaceouter");
  138.  
  139.        CALL topipe(pipe, 'layout bevel=3 vertical gadgettext="'getstr(201,"File")'" spaceinner spaceouter');
  140.  
  141.         CALL topipe(pipe, 'label gadgettext="'getstr(202,"Animation-path:")'" unattached');
  142.         gads.path = topipe(pipe, 'getfile childlabel minwidth=200 save filename='config.PATH);
  143.  
  144.         CALL topipe(pipe, 'label gadgettext="'getstr(203,"Animation-format:")'" unattached');
  145.         gads.animformat = topipe(pipe, 'chooser childlabel weightedwidth=0 popup chooserlabels="IFF-ANIM 5|IFF-ANIM 7S|IFF-ANIM 7L" selected='config.ANIM_FORMAT);
  146.  
  147.        CALL topipe(pipe, "layoutend");
  148.  
  149.        CALL topipe(pipe, 'layout bevel=3 vertical centerjustify gadgettext="'getstr(204,"Animation")'" spaceinner spaceouter');
  150.  
  151.         CALL topipe(pipe, 'label gadgettext="'getstr(205,"Number of frames:")'" unattached');
  152.         gads.numframes = topipe(pipe, "integer childlabel weightedwidth=0 minnumber=2 maxnumber=2000 arrows disable="1-config.SCALE" defnumber="config.NUM_FRAMES);
  153.  
  154.         CALL topipe(pipe, 'label gadgettext="'getstr(206,"Direction:")'" unattached');
  155.         gads.direction = topipe(pipe, 'radiobutton childlabel radiolabels="'getstr(207,"In")'|'getstr(208,"Out")'" selected='config.DIRECTION);
  156.  
  157.        CALL topipe(pipe, "layoutend");
  158.  
  159.        CALL topipe(pipe, 'layout bevel=3 gadgettext="'getstr(209,"Scaling")'" spaceinner spaceouter');
  160.  
  161.         CALL topipe(pipe, "layout bevel=0 centerjustify vertical spaceinner spaceouter");
  162.  
  163.          CALL topipe(pipe, 'label gadgettext="'getstr(210,"Scale?")'" unattached');
  164.          gads.scale = topipe(pipe, "checkbox childlabel selected="config.SCALE);
  165.  
  166.         CALL topipe(pipe, "layoutend")
  167.  
  168.         CALL topipe(pipe, "layout bevel=3 centerjustify vertical spaceinner spaceouter");
  169.  
  170.          CALL topipe(pipe, 'label gadgettext="'getstr(211,"Width:")'" unattached');
  171.          gads.destwidth = topipe(pipe, "integer childlabel weightedwidth=0 minnumber=16 maxnumber=2048 arrows disable="1-config.SCALE" defnumber="config.DEST_WIDTH);
  172.  
  173.          CALL topipe(pipe, 'label gadgettext="'getstr(212,"Height:")'" unattached');
  174.          gads.destheight = topipe(pipe, "integer childlabel weightedwidth=0 minnumber=10 maxnumber=2048 arrows disable="1-config.SCALE" defnumber="config.DEST_HEIGHT);
  175.  
  176.          CALL topipe(pipe, 'space minheight=5');
  177.  
  178.          CALL topipe(pipe, 'label gadgettext="'getstr(213,"Resolution:")'" unattached');
  179.          res = checkresolution(config.DEST_WIDTH, config.DEST_HEIGHT);
  180.          gads.resolution = topipe(pipe, 'chooser childlabel popup chooserlabels="'getstr(214,"custom|80x60|160x120|320x240|640x480|800x600|1024x768|1280x1024|1600x1200")'" disable='1-config.SCALE' selected='res);
  181.  
  182.         CALL topipe(pipe, "layoutend");
  183.  
  184.        CALL topipe(pipe, "layoutend");
  185.  
  186.       CALL topipe(pipe, "layoutend");
  187.  
  188.       CALL topipe(pipe, "layout spaceouter spaceinner");
  189.       gads.create = topipe(pipe, 'button gadgettext="'getstr(215, "Create")'" close');
  190.       gads.cancel = topipe(pipe, 'button gadgettext="'getstr(101, "Cancel")'" close');
  191.       CALL topipe(pipe, "layoutend");
  192.       CALL topipe(pipe, "open");
  193.       END;
  194.    ELSE DO
  195.       pipe="gui_err";
  196.       END;
  197.  
  198.    RETURN pipe;
  199.  
  200. /* CreateAnimation(): Create the animation corresponding to the user-definitions. */
  201. CreateAnimation: PROCEDURE EXPOSE app. config. anim_fmt.
  202.    IF app.USE_PRESETS = 1 THEN DO  /* for test only */
  203.       COORDS_A.RMIN = -2.000000;
  204.       COORDS_A.RMAX = 1.000000;
  205.       COORDS_A.IMIN = -1.125000;
  206.       COORDS_A.IMAX = 1.125000;
  207.       COORDS_A.JKRE = -0.720000;
  208.       COORDS_A.JKIM = -0.260000;
  209.  
  210.       COORDS_B.RMIN = -1.313750;
  211.       COORDS_B.RMAX = -0.346250;
  212.       COORDS_B.IMIN = -0.142500;
  213.       COORDS_B.IMAX = 0.585000;
  214.       COORDS_B.JKRE = -0.720000;
  215.       COORDS_B.JKIM = -0.260000;
  216.       END;
  217.  
  218.    ELSE DO
  219.       CALL DisplayRequest(app.name, getstr(1, "Please make some zooms for selecting the first frame"), getstr(100, "OK"), app.PUBSCREEN);
  220.       'GET_COORDINATES' 'COORDS_A'    /* Get first coordinates */
  221.       CALL DisplayRequest(app.name, getstr(2, "Please make some zooms for selecting the second frame"), getstr(100, "OK"), app.PUBSCREEN);
  222.       'GET_COORDINATES' 'COORDS_B'    /* Get second coordinates */
  223.       END;
  224.  
  225.    IF ((COORDS_A.RMIN = COORDS_B.RMIN) & (COORDS_A.RMAX = COORDS_B.RMAX) & (COORDS_A.IMIN = COORDS_B.IMIN) & (COORDS_A.IMAX = COORDS_B.IMAX)) THEN DO
  226.       CALL DisplayRequest(app.name, getstr(301, "Error: The second frame must be different to the second frame!"),  getstr(100, "OK"), app.PUBSCREEN);
  227.       EXIT 10;
  228.       END;
  229.  
  230.    IF app.DEBUG > 0 THEN DO
  231.       SAY "First coordinates:";
  232.       SAY "  COORDS_A.RMIN: " COORDS_A.RMIN;
  233.       SAY "  COORDS_A.RMAX: " COORDS_A.RMAX;
  234.       SAY "  COORDS_A.IMIN: " COORDS_A.IMIN;
  235.       SAY "  COORDS_A.IMAX: " COORDS_A.IMAX;
  236.       SAY "  COORDS_A.JKRE: " COORDS_A.JKRE;
  237.       SAY "  COORDS_A.JKIM: " COORDS_A.JKIM;
  238.       END;
  239.  
  240.    RMIN_MOD = (COORDS_B.RMIN - COORDS_A.RMIN) / (config.NUM_FRAMES - 1);
  241.    RMAX_MOD = (COORDS_A.RMAX - COORDS_B.RMAX) / (config.NUM_FRAMES - 1);
  242.    IMIN_MOD = (COORDS_B.IMIN - COORDS_A.IMIN) / (config.NUM_FRAMES - 1);
  243.    IMAX_MOD = (COORDS_A.IMAX - COORDS_B.IMAX) / (config.NUM_FRAMES - 1);
  244.  
  245.    IF app.DEBUG > 0 THEN DO
  246.       SAY "Mods:";
  247.       SAY "  RMIN_MOD: " RMIN_MOD;
  248.       SAY "  RMAX_MOD: " RMAX_MOD;
  249.       SAY "  IMIN_MOD: " IMIN_MOD;
  250.       SAY "  IMAX_MOD: " IMAX_MOD;
  251.       END;
  252.  
  253.    IF config.DIRECTION = 0 THEN DO        /* init direction */
  254.       SAY "IN IN IN"
  255.       FIRST = 0; LAST = config.NUM_FRAMES - 1; STEP = 1;
  256.       END;
  257.    ELSE DO
  258.       LAST = 0; FIRST = config.NUM_FRAMES - 1; STEP = -1;
  259.       END;
  260.  
  261.    COORDS.RMIN = COORDS_A.RMIN;       /* first frame */
  262.    COORDS.RMAX = COORDS_A.RMAX;
  263.    COORDS.IMIN = COORDS_A.IMIN;
  264.    COORDS.IMAX = COORDS_A.IMAX;
  265.    COORDS.JKRE = COORDS_A.JKRE;
  266.    COORDS.JKIM = COORDS_A.JKIM;
  267.  
  268.    DO S=FIRST TO LAST BY STEP
  269.       PIC_PATH = app.TEMP_DIR || app.TEMP_FILENAME || '.' || RIGHT(S+1, 4, "0");
  270.       /*SAY "PIC_PATH:" PIC_PATH;*/
  271.  
  272.       IF app.DEBUG > 0 THEN DO
  273.          SAY "Between coordinates:";
  274.          SAY "  S: " S;
  275.          SAY "  COORDS.RMIN: " COORDS.RMIN;
  276.          SAY "  COORDS.RMAX: " COORDS.RMAX;
  277.          SAY "  COORDS.IMIN: " COORDS.IMIN;
  278.          SAY "  COORDS.IMAX: " COORDS.IMAX;
  279.          END;
  280.  
  281.       'SET_COORDINATES' 'COORDS'
  282.       'RENDER' 'FORCE'
  283.       CALL DELAY(15);
  284.  
  285.       'SAVE_PICTURE' PIC_PATH 'FORCE';
  286.       IF config.SCALE = 1 THEN DO
  287.          IF OPEN('sc', app.SCALE_SCRIPT_PATH, "W") THEN DO
  288.             WRITELN('sc', "stack 50000");
  289.             WRITELN('sc', app.GFXCON_PATH PIC_PATH "FASTDITHER NOPROGRESS BOXFIT" config.DEST_WIDTH config.DEST_HEIGHT);
  290.             CLOSE('sc');
  291.             ADDRESS COMMAND "Execute" app.SCALE_SCRIPT_PATH;
  292.             END;
  293.          END;
  294.  
  295.       IF app.TRACE_FLAG = 1 THEN
  296.          CALL DisplayRequest("Test Movie", "Step" S, "weiter", app.PUBSCREEN);
  297.  
  298.       COORDS.RMIN = COORDS.RMIN + RMIN_MOD;
  299.       COORDS.RMAX = COORDS.RMAX - RMAX_MOD;
  300.       COORDS.IMIN = COORDS.IMIN + IMIN_MOD;
  301.       COORDS.IMAX = COORDS.IMAX - IMAX_MOD;
  302.       END S;
  303.  
  304.    ADDRESS COMMAND;                   /* create animation */
  305.    ANIM_PATH = config.PATH;
  306.    SAY ""; SAY "create iff-animation...  (" || ANIM_PATH || ")";
  307.    tmp = config.ANIM_FORMAT;
  308.    app.BUILDANIM_PATH app.TEMP_DIR || app.TEMP_FILENAME || '.0001' ANIM_PATH anim_fmt.tmp;
  309.    SAY "command: " app.BUILDANIM_PATH app.TEMP_DIR || app.TEMP_FILENAME || '.0001' ANIM_PATH anim_fmt.tmp;
  310.    SAY "";
  311.  
  312.    SAY "delete temporary frames..."   /* delete temporary files */
  313.    DO S=1 TO config.NUM_FRAMES
  314.       PIC_PATH = app.TEMP_DIR || app.TEMP_FILENAME || '.' || RIGHT(S, 4, "0");
  315.       'delete' PIC_PATH;
  316.       END S;
  317.    SAY "delete scale-script..."
  318.    'delete' app.SCALE_SCRIPT_PATH;
  319.  
  320.    SAY "ready";                       /* ready */
  321.    CALL DisplayRequest(app.name, getstr(3, "Ready!"), getstr(100, "OK"), app.PUBSCREEN);
  322.  
  323.    IF app.DEBUG > 1 THEN DO
  324.       SAY "Second coordinates:";
  325.       SAY "  COORDS_B.RMIN: " COORDS_B.RMIN;
  326.       SAY "  COORDS_B.RMAX: " COORDS_B.RMAX;
  327.       SAY "  COORDS_B.IMIN: " COORDS_B.IMIN;
  328.       SAY "  COORDS_B.IMAX: " COORDS_B.IMAX;
  329.       SAY "  COORDS_B.JKRE: " COORDS_B.JKRE;
  330.       SAY "  COORDS_B.JKIM: " COORDS_B.JKIM;
  331.       END;
  332.  
  333.    RETURN 0;
  334.  
  335. /* DisplayRequest(): Display a request and return result */
  336. DisplayRequest:
  337.    PARSE ARG Title,Body,Gadgets,Screen;
  338.    ADDRESS COMMAND 'RequestChoice >t:rc.tmp TITLE="'Title'" BODY="'Body'" PUBSCREEN="'Screen'" GADGETS="'Gadgets'"';
  339.  
  340.    IF OPEN(var, 't:rc.tmp', read) THEN DO
  341.       res = READLN(var);
  342.       CALL CLOSE(var);
  343.       END;
  344.    ELSE res = 0;
  345.    ADDRESS COMMAND 'delete t:rc.tmp'
  346.    RETURN res;
  347.  
  348. /* LoadConfig(): Load the saved configuration. */
  349. /*               Routine taken from 'ArtConvert.rexx' and modified */
  350. LoadConfig: PROCEDURE EXPOSE app. config.
  351.    config.NUM_FRAMES = 5;
  352.    config.DIRECTION = 0;   /* IN  OUT */
  353.    config.PATH = "ram:test.anim";
  354.    config.SCALE = 1;
  355.    config.DEST_WIDTH = 320;
  356.    config.DEST_HEIGHT = 240;
  357.    config.ANIM_FORMAT = 0;   /* ANIM5  ANIM7S  ANIM7L */
  358.  
  359.    IF OPEN('fh', app.configfile, 'R') THEN DO
  360.       IF READLN('fh') == 'Create_FM-Anim1' THEN DO
  361.          DO UNTIL EOF("fh")
  362.             line = STRIP(READLN('fh'));
  363.             PARSE VAR line option "=" setting;
  364.             option = UPPER(STRIP(option));
  365.             setting = STRIP(setting);
  366.             config.option = setting;
  367.             END;
  368.          END;
  369.       CLOSE('fh');
  370.       END;
  371.  
  372.    RETURN 0;
  373.  
  374. /* SaveConfig(): Save the configuration. */
  375. /*               Routine taken from 'ArtConvert.rexx' and modified */
  376. SaveConfig: PROCEDURE EXPOSE app. config.
  377.    IF OPEN('fh', app.configfile, 'W') THEN DO
  378.       WRITELN("fh", "Create_FM-Anim1");
  379.       WRITELN("fh", "NUM_FRAMES =" config.NUM_FRAMES);
  380.       WRITELN("fh", "DIRECTION =" config.DIRECTION);
  381.       WRITELN("fh", "PATH =" config.PATH);
  382.       WRITELN("fh", "SCALE =" config.SCALE);
  383.       WRITELN("fh", "DEST_WIDTH =" config.DEST_WIDTH);
  384.       WRITELN("fh", "DEST_HEIGHT =" config.DEST_HEIGHT);
  385.       WRITELN("fh", "ANIM_FORMAT = " config.ANIM_FORMAT);
  386.       CLOSE('fh');
  387.       END;
  388.    ELSE DO
  389.       DisplayRequest(getstr(100, 'OK'), getstr(302, 'Error: Could not save config file »%s«!', app.configfile));
  390.       END;
  391.    RETURN 0;
  392.  
  393. /* Init(): Initialize environment */
  394. /*         Routine taken from 'ArtConvert.rexx' and modified */
  395. Init: PROCEDURE EXPOSE app.
  396.    success = 1;
  397.    app.name = 'Create_FM-Anim';
  398.    app.configfile = "FLASHMANDEL:arexx/Create_FM-Anim.cfg";
  399.    lf='0a'x;
  400.  
  401.    app.catalog = 0;
  402.    app.locale = 0;
  403.    IF SHOW('L', 'locale.library') THEN DO
  404.       app.locale = 1;
  405.    END;
  406.    ELSE DO
  407.       IF ADDLIB('locale.library', 0, -30, 0) THEN DO
  408.          app.locale = 1;
  409.       END;
  410.    END;
  411.    IF app.locale = 1 THEN DO
  412.       app.catalog = OpenCatalog(app.name".catalog", 'english', 12);
  413.    END;
  414.    RETURN success;
  415.  
  416. /* Cleanup(): Cleanup environment. */
  417. Cleanup:
  418.    IF SHOW("P", app.portname) THEN DO
  419.       ADDRESS VALUE app.portname;
  420.       ;
  421.       END;
  422.    RETURN 0;
  423.    EXIT;
  424.  
  425. /* topipe(): send lines to awn-pipe including error-checking. */
  426. /*           Routine taken from 'ArtConvert.rexx' and modified */
  427. topipe: PROCEDURE
  428.    PARSE ARG pipe, out;              /* get line to output */
  429.    CALL WRITELN(pipe, out);          /* write to the pipe */
  430.    res = READLN(pipe);               /* get responce and parse it. */
  431.    PARSE VAR res res1 res2 .
  432.    IF res1 = 'ok' THEN RETURN(res2); /* if all is ok return the second part of the responce (usualy the GID) */
  433.  
  434.    /* something went wrong, we notify the user then exit */
  435.    /* show problem line and responce (reponce may be just a blank line)*/
  436.    DisplayRequest(app.name, getstr(101, 'Cancel'), getstr(303, "GUI error »%s« / »%s«! Please report to author.", out, res));
  437.    CALL CLOSE(pipe.file);
  438.    Cleanup();
  439.    EXIT 20;
  440.  
  441. /* getstr(): Get string from catalog. */
  442. /*           Routine taken from 'ArtConvert.rexx' and modified */
  443. getstr: PROCEDURE EXPOSE app.catalog
  444.    PARSE ARG msgno, msgstring;
  445.    IF app.catalog ~= 0 THEN msgstring = GetCatalogStr(app.catalog, msgno, msgstring);
  446.    DO i = 3 TO ARG()
  447.       PARSE VAR msgstring fore '%s' aft;
  448.       msgstring = fore || ARG(i) || aft;
  449.       END;
  450.    RETURN msgstring;
  451.  
  452. /* checkresolution(): Check for standard-resolution. */
  453. /*                    Routine taken from 'ArtConvert.rexx' and modified */
  454. checkresolution: PROCEDURE EXPOSE resolution.
  455.    PARSE ARG checkwidth,checkheight;
  456.    res = 0;
  457.  
  458.    DO i=0 TO resolution.count - 1
  459.       IF (checkwidth = resolution.i.width) & (checkheight = resolution.i.height) THEN DO
  460.          res = i + 1;
  461.          LEAVE;
  462.          END;
  463.       END;
  464.    RETURN res;
  465.  
  466.